<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="AboutClass">

    <div class="layui-card-body padding-left-40 layui-col-space10">

        {if $account_show}
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("所属学校")}:</label>
            <div class="layui-input-block">

                <select name="account_id" lay-search class="layui-select" lay-filter="platform">
                    <option value=''>-- {:lang('全部')} --</option>
                    {foreach $account_arr as $key => $name}

                    <option value="{$key}" >{$name|default=''}</option>

                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("老师名称")}:</label>
            <div class="layui-input-block">

                <select class="layui-select teacher" name="user_id">
                    <option value=''>-- {:lang('全部')} --</option>
                    {foreach $teacher_arr as $k=>$v}

                    <option  value="{$k}">{$v}</option>

                    {/foreach}
                </select>
            </div>
        </div>
        {/if}
        <div class="layui-col-md12">
            <label class="layui-form-label">{:Lang("班级名字")}:</label>
            <div class="layui-input-block">

                <input name="name" value='' required class="layui-input " placeholder="{:lang('请输入班级名字')}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:Lang("允许报名人数")}:</label>
            <div class="layui-input-block" >
                <input name="allow_num" value='' required class="layui-input " placeholder="{:lang('请输入允许报名人数')}">
            </div>
        </div>
    </div>
    <div class="hr-line-dashed"></div>


    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
</form>
<script>
    // 指向元素为 `<select lay-filter="test"></select>` 的选择事件
    form.on('select(platform)', function(data){

        $.ajax({
            type : 'get',
            url  : "{:sysuri('common/ajax/getTeacherList')}",
            data : {account_id:data.value},
            success:function (res) {
                if (res.code == 1) {
                    var html = "<option value=''>{:lang('-- 请选择 --')}</option>";

                    let data = res.data;
                    for (var i in data) {

                        html += "<option value='"+i+"'>"+data[i]+"</option>";
                    }

                    $('.teacher').html(html);

                    layui.form.render('select'); // 仅渲染 select 元素
                }
            }
        })
    });
</script>